package com.myatest;

import android.app.Notification;
import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;

import com.audiorecorder.AudioTestActivity;
import com.blankj.utilcode.util.NotificationUtils;
import com.calendarpicker.CalendarpickerActivity;
import com.dialogtest.DialogTestActivity;
import com.navigationtest.NavigationMainActivity;
import com.pbase.tools.Logger;
import com.seepic.SeepicActivity;
import com.textselect.TextselectActivity;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    int flag= 0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViewById(R.id.btn_goto_test_textselect).setOnClickListener(v -> {
            startActivity(new Intent(this, TextselectActivity.class));
        });
        findViewById(R.id.btn_goto_test_audio).setOnClickListener(v -> {
            startActivity(new Intent(this, AudioTestActivity.class));
        });
        findViewById(R.id.btn_goto_test_notification).setOnClickListener(v -> {
            Logger.d(getClass(),
                    "Notification enable " + NotificationUtils.areNotificationsEnabled());
            //自动把通知栏拉下来
            //NotificationUtils.setNotificationBarVisibility(true);


            NotificationUtils.notify("测试通知", flag++, new NotificationUtils.ChannelConfig(""   , "测试通知",
                    NotificationUtils.IMPORTANCE_HIGH), builder -> {
                Intent intent = new Intent(this, TextselectActivity.class);
                PendingIntent pendingIntent = PendingIntent.getActivity(this, 1 , intent,
                        PendingIntent.FLAG_CANCEL_CURRENT);
                builder
                        //设置通知右边的小图标
                        .setSmallIcon(R.drawable.ic_launcher_background)
                        //设置通知左边的大图标
                        .setLargeIcon(BitmapFactory.decodeResource(getResources(),
                                R.drawable.loading, null))
                        //通知首次出现在通知栏，带上升动画效果的
                        .setTicker("通知来了")
                        //通知产生的时间，会在通知信息里显示
                        .setWhen(System.currentTimeMillis())
                        //标题
                        .setContentTitle("测试通知")
                        //内容
                        .setContentText("测试通知测试通知测试通知测试通知测试通知测试通知测试通知测试通知测试通知")
                        //意图
                        //.setContentIntent(pendingIntent)
                        .setFullScreenIntent(pendingIntent, true)
                        //点击消失
                        .setAutoCancel(true)
                        //设置角标累加值
                        .setNumber(1)
                        //向通知添加声音、闪灯和振动效果的最简单、最一致的方式是使用当前的用户默认设置，使用defaults属性，可以组合：
                        .setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND)
                        .build();
            });
        });
        findViewById(R.id.btn_goto_test_seepic).setOnClickListener(v -> {
            startActivity(new Intent(this, SeepicActivity.class));
        });
        findViewById(R.id.btn_goto_test_calendarpicker).setOnClickListener(v -> {
            startActivity(new Intent(this, CalendarpickerActivity.class));
        });
        findViewById(R.id.btn_goto_test_dialog).setOnClickListener(v -> {
            startActivity(new Intent(this, DialogTestActivity.class));
        });
        findViewById(R.id.btn_goto_test_navigation).setOnClickListener(v -> {
            startActivity(new Intent(this, NavigationMainActivity.class));
        });
    }
}